package com.xiaoyu.cloudmusic.config;

import com.xiaoyu.cloudmusic.interceptor.JWTInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //这里配置携带token和不携带token路径。
        registry.addInterceptor(new JWTInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/playList/recommend").excludePathPatterns("/playList/resource")
                .excludePathPatterns("/playList/banner").excludePathPatterns("/playList/detail")
                .excludePathPatterns("/playList/update").excludePathPatterns("/playList/coverupload")
                .excludePathPatterns("/playList/tracksAdd").excludePathPatterns("/playList/SongList")
                .excludePathPatterns("/login/**")
                .excludePathPatterns("/avatar/**")
                .excludePathPatterns("/cover/**")
                .excludePathPatterns("/QQmusic/**")
                .excludePathPatterns("/VipSongsDownload/**")
                .excludePathPatterns("/NCmusic/**")
                .excludePathPatterns("/playList/addComment")
                .excludePathPatterns("/playList/**")
                .excludePathPatterns("/admin/**");
    }
}